<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.UserRegistration}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup id="messagePanel" layout="block">
                <p:messages />
            </h:panelGroup>
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputLabel value="#{bundle.CreateUsersLabel_username}" for="username" />
                    <p:inputText id="username" value="#{usersController.selected.username}" title="#{bundle.CreateUsersTitle_username}"  required="true" requiredMessage="#{bundle.CreateUsersRequiredMessage_username}"/>
                    <h:outputLabel value="#{bundle.CreateUsersLabel_password}" for="password" />
                    <p:password id="password" value="#{usersController.selected.password}" required="true" match="passwordConfirm" feedback="true" validatorMessage="Your password must be greater than or equal 5 symbols" requiredMessage="#{bundle.CreateUsersRequiredMessage_password}">
                        <f:validateLength minimum="5" />
                    </p:password>
                    <h:outputLabel value="Confirm password" for="passwordConfirm" />
                    <p:password id="passwordConfirm" value="#{usersController.selected.password}" 
                                required="true" feedback="true" 
                                requiredMessage="#{bundle.CreateUsersRequiredMessage_password}"/>
                    <h:outputLabel value="#{bundle.CreateUsersLabel_name}" for="name" />
                    <p:inputText id="name" value="#{usersController.selected.name}" 
                                 title="#{bundle.CreateUsersTitle_name}" 
                                 required="true"
                                 requiredMessage="Please enter your name"/>
                    <h:outputLabel value="#{bundle.CreateUsersLabel_address}" 
                                   for="address" />
                    <p:inputText id="address" 
                                 value="#{usersController.selected.address}" 
                                 title="#{bundle.CreateUsersTitle_address}" 
                                 required="true" 
                                 requiredMessage="Please enter your address"/>
                    <h:outputLabel value="#{bundle.CreateUsersLabel_phoneNum}" 
                                   for="phoneNum" />
                    <p:inputText id="phoneNum" value="#{usersController.selected.phoneNum}" 
                                 title="#{bundle.CreateUsersTitle_phoneNum}" 
                                 required="true"
                                 requiredMessage="Please enter your name"/>
                    <h:outputLabel value="#{bundle.CreateUsersLabel_drivingLicenseNum}" 
                                   for="drivingLicenseNum" />
                    <p:inputText id="drivingLicenseNum" 
                                 value="#{usersController.selected.drivingLicenseNum}" 
                                 title="#{bundle.CreateUsersTitle_drivingLicenseNum}" 
                                 required="true" 
                                 requiredMessage="Please enter your driving license number"/>
                </h:panelGrid>
                <br />
                <h:panelGrid columns="2">
                    <h:commandLink action="#{usersController.createNewUser()}" value="#{bundle.Submit}" />
                    <h:commandLink action="index.xhtml?faces-redirect=true" value="Cancel" immediate="true"/>
                </h:panelGrid>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
